import { APITool, IsMockInit } from "@/utils/frame/APITool";
import { DefaultHeader } from "@/api/index";
import { User } from "@/model/RBAC/User";

export default class UserAPI {
  @IsMockInit
  public static login(username: string, password: string): Promise<any> {
    return APITool.post("/api/v0/Login", {
      username,
      password
    });
  }

  @IsMockInit
  public static list(): Promise<any> {
    return APITool.get("/api/v0/User", {
      headers: { ...new DefaultHeader() }
    });
  }

  @IsMockInit
  public static create(username: string, password: string): Promise<any> {
    return APITool.post("/api/v0/User", {
      username,
      password
    });
  }

  @IsMockInit
  public static update(user: User): Promise<any> {
    return APITool.put("/api/v0/User", {
      ...user
    });
  }
}
